/* GUI CONVERTED from rewocr.p (converter v1.76) Fri Sep 28 01:37:59 2001 */
/* rewocr.p - CREATE CUMULATIVE WORK ORDER FOR REPETITIVE               */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.7.1.6 $                                                     */
/*V8:ConvertMode=Maintenance                                            */
/* REVISION: 6.0      LAST MODIFIED: 06/18/90   BY: emb      */
/* REVISION: 6.0      LAST MODIFIED: 09/25/90   BY: SMM   *D072*/
/* REVISION: 6.0      LAST MODIFIED: 10/10/90   BY: SMM   *D085*/
/* REVISION: 6.0      LAST MODIFIED: 08/12/91   BY: pma   *D806*/
/* REVISION: 7.0      LAST MODIFIED: 10/08/91   BY: pma *F003*          */
/* REVISION: 7.0      LAST MODIFIED: 01/25/92   BY: pma *F003*          */
/* REVISION: 7.0      LAST MODIFIED: 02/20/92   BY: pma *F217*          */
/* REVISION: 7.0      LAST MODIFIED: 02/25/92   BY: emb *F227*          */
/* REVISION: 7.0      LAST MODIFIED: 02/20/92   BY: pma *F085*          */
/* REVISION: 7.0      LAST MODIFIED: 03/09/92   BY: smm *F230*          */
/* REVISION: 7.3      LAST MODIFIED: 11/02/92   BY: emb *G269*          */
/* REVISION: 7.3      LAST MODIFIED: 08/31/93   BY: emb *GE62*          */
/* REVISION: 7.3      LAST MODIFIED: 11/01/94   by: ame *GN86*          */
/* REVISION: 8.5      LAST MODIFIED: 04/26/95   BY: sxb *J04D*          */
/* REVISION: 8.5      LAST MODIFIED: 06/16/95   BY: rmh *J04R*          */
/* REVISION: 8.5      LAST MODIFIED: 02/28/96   BY: kxn *J0DC*          */
/* REVISION: 8.5      LAST MODIFIED: 03/05/96   by: jym *G1N7*          */
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   by: *K1Q4* Alfred Tan   */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   by: *N014* Murali Ayyagari */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   by: *N0KP* myb             */
/* REVISION: 9.1      LAST MODIFIED: 09/30/00   BY: *L0Y1* Kirti Desai     */
/* Old ECO marker removed, but no ECO header exists *F0PN*               */
/* $Revision: 1.7.1.6 $    BY: Irine D'Mello  DATE: 09/10/01  ECO: *M164*      */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
{pxmaint.i}

{pxphdef.i wocmnrtn}

define input parameter part like wo_part.
define input parameter effdate as date.

define new shared variable eff_date as date.
define shared variable routing as character.
define shared variable bom_code as character.
define shared variable wo_recno as recid.
define shared variable site like rps_site no-undo.
define shared variable prline like rps_line no-undo.

define variable glx_mthd like cs_method.
define variable glx_set like cs_set.
define variable cur_mthd like cs_method.
define variable cur_set like cs_set.
define variable wolot     like wo_lot  no-undo.
define variable l_errorno as   integer no-undo.

find first clc_ctrl no-lock no-error.

if not available clc_ctrl
then do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.

   {gprun.i ""gpclccrt.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

   find first clc_ctrl no-lock.
end.
/*GUI*/ if global-beam-me-up then undo, leave.


find pt_mstr no-lock
   where pt_part = part no-error.

eff_date = effdate.

do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.

   {mfnxtsq.i wo_mstr wo_lot woc_sq01 wolot}
end.
/*GUI*/ if global-beam-me-up then undo, leave.


do transaction:
/*GUI*/ if global-beam-me-up then undo, leave.


   create wo_mstr.

   assign
      wo_nbr = part
      wo_lot = wolot
      wo_part = part
      wo_type = "C"
      wo_ord_date = today
      wo_rel_date = if effdate <> ?
                    then
                       effdate
                    else
                       today
      wo_routing = routing
      wo_bom_code = bom_code
      wo_status = "R"
      wo_line = prline
      wo_site = site
      wo_lot_rcpt = clc_relot_rcpt.

   if recid(wo_mstr) = -1 then .

   wo_recno = recid(wo_mstr).

   /*DETERMINE COSTING METHOD*/
   {gprun.i ""csavg01.p"" "(input wo_part,
                            input wo_site,
                            output glx_set,
                            output glx_mthd,
                            output cur_set,
                            output cur_mthd)"
   }
/*GUI*/ if global-beam-me-up then undo, leave.


   if glx_mthd = "AVG"
   then
      wo_var = no.
   else do:
      find first woc_ctrl no-lock.
      wo_var = woc_var.
   end.

   if available pt_mstr
   then do:

      /* ASSIGN DEFAULT RECEIPT STATUS AND ACTIVE FLAG */
      {pxrun.i &PROC    = 'get_default_wo_rctstat'
               &PROGRAM = 'wocmnrtn.p'
               &HANDLE  = ph_wocmnrtn
               &PARAM   = "(
                            input  wo_part,
                            input  wo_site,
                            output wo_rctstat,
                            output wo_rctstat_active,
                            output l_errorno
                           )"
      }

      /* ASSIGN DEFAULT VARIANCE ACCOUNT SUB-ACCOUNT AND COST CENTER CODE. */
      run assign_default_wo_acct(buffer wo_mstr,
                                 input pt_prod_line).

   end. /* IF AVAILABLE PT_MSTR */

   {gprun.i ""woworlc.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* DO TRANSACTION */

/* INCLUDE FILE WHICH CONTAINS PROCEDURE assign_default_wo_acct */
{woacct.i}
